const Router = require('koa-router');

//控制器
const { addCart, updateCart, deleteCart, getCart } = require('../controller/cart.controller');

//中间件
const { auth } = require('../middleware/auth.middleware');
const { validator } = require('../middleware/validator.middleware');

const router = new Router({ prefix: '/cart' });

//添加购物车
router.post('/add', auth, validator({ goods_id: 'number', goods_number: 'number' }), addCart);

//更新购物车
router.patch('/update', auth, validator({ id: 'number', goods_number: 'number' }), updateCart);

//删除购物车
router.delete('/delete', auth, validator({ ids: 'array' }), deleteCart);

//获取购物车列表接口
router.get('/getCart', auth, getCart);

module.exports = router;